package cn.fyl.basic.interceptor.config;

import cn.fyl.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MyConfig implements WebMvcConfigurer {
    /**
     * 配置类，相当于mvc中的xml
     */
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)//使用的拦截器
                .addPathPatterns("/**") // 需要拦截的
                .excludePathPatterns("/login/**") // 放行登陆
                .excludePathPatterns("/fastdfs/**")
                .excludePathPatterns("/verifyCode/**") // 放行验证码
                .excludePathPatterns("/user/phoneRegister") // 放行手机号注册
                .excludePathPatterns("/shop/settlement")// 放行店铺入驻
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**");// 放行swagger


    }
}
